import initState from './initState'
import types from './types'

const loginReducer = (previousState = initState(), action) => {
  switch (action.type) {
    case types.LOGIN_STATE:
      return {
        ...previousState,
        ...action.payload
      }
    case types.LOGOUT:
      return {
        ...initState()
      }
    default:
      return previousState
  }
}

export default loginReducer
